import request from '@/utils/request'

// 非诉讼订单API
class NonLawsuitOrderApi {
  /**
   * 创建非诉讼订单
   * @param data 订单数据
   */
  async create(data: any) {
    return request({
      url: '/crm/non-lawsuit-order/create',
      method: 'post',
      data,
    })
  }

  /**
   * 更新非诉讼订单
   * @param id 订单ID
   * @param data 更新数据
   */
  async update(id: number, data: any) {
    return request({
      url: `/crm/non-lawsuit-order/${id}/update`,
      method: 'put',
      data,
    })
  }

  /**
   * 获取非诉讼订单详情
   * @param id 订单ID
   */
  async detail(id: number) {
    return request({
      url: `/crm/non-lawsuit-order/${id}/detail`,
      method: 'get',
    })
  }

  /**
   * 删除非诉讼订单
   * @param id 订单ID
   */
  async delete(id: number) {
    return request({
      url: `/crm/non-lawsuit-order/${id}/delete`,
      method: 'delete',
    })
  }

  /**
   * 获取非诉讼订单列表
   * @param params 查询参数
   */
  async list(params?: any) {
    return request({
      url: '/crm/non-lawsuit-order/list',
      method: 'get',
      params,
    })
  }

  /**
   * 获取非诉讼订单统计数据
   * @param params 查询参数
   */
  async statistics(params?: any) {
    return request({
      url: '/crm/non-lawsuit-order/statistics',
      method: 'get',
      params,
    })
  }

  /**
   * 审核非诉讼订单
   * @param id 订单ID
   * @param data 审核数据
   */
  async audit(id: number, data: any) {
    return request({
      url: `/crm/non-lawsuit-order/${id}/audit`,
      method: 'post',
      data,
    })
  }

  /**
   * 取消非诉讼订单
   * @param id 订单ID
   * @param data 取消原因
   */
  async cancel(id: number, data: any) {
    return request({
      url: `/crm/non-lawsuit-order/${id}/cancel`,
      method: 'post',
      data,
    })
  }

  /**
   * 获取非诉讼订单状态列表
   */
  async getStatusList() {
    return request({
      url: '/crm/non-lawsuit-order/status-list',
      method: 'get',
    })
  }
}

export const nonLawsuitOrderApi = new NonLawsuitOrderApi()
